cmake_minimum_required(VERSION 3.10)
project(000026 CXX)

set(CMAKE_CXX_STANDARD 11)

# 添加源文件
add_executable(main main/main.cpp)

# 将debug和release版本生成目录均设置为对应同一目录
if(${CMAKE_GENERATOR} MATCHES "Visual Studio*")
	set_target_properties(main PROPERTIES
			RUNTIME_OUTPUT_DIRECTORY_DEBUG "${PROJECT_SOURCE_DIR}/main")
	set_target_properties(main PROPERTIES
			RUNTIME_OUTPUT_DIRECTORY_RELEASE "${PROJECT_SOURCE_DIR}/main")
else()
	set_target_properties(main PROPERTIES
			RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/main")

endif()

# 添加依赖
add_library(dis_pset    Source_CPgrid/dis_pset.cpp)
add_library(FileMapping Source_CPgrid/FileMapping.cpp)
add_library(mesh        Source_CPgrid/mesh.cpp)

add_library(DenseMatrix  Source_Dense/DenseMatrix.cpp)
add_library(DenseSolver  Source_Dense/DenseSolver.cpp)

add_library(RBF_Interpolation Source_RBF_Interpolation/RBF_Interpolation.cpp)
add_library(PickingSpots Source_RBF_Interpolation/PickingSpots.cpp)
add_library(RBF_function Source_RBF_Interpolation/RBF_function.cpp)

# 指定依赖
target_link_libraries(mesh	PUBLIC FileMapping)
target_link_libraries(DenseSolver	PUBLIC DenseMatrix mesh)
target_link_libraries(RBF_Interpolation	PUBLIC PickingSpots RBF_function DenseSolver mesh)

target_link_libraries(main mesh RBF_Interpolation)

# 指定include目录
include_directories(${PROJECT_SOURCE_DIR})

# 查找OpenMP库
find_package(OpenMP REQUIRED)
if(OPENMP_FOUND)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
	set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
	target_link_libraries(main OpenMP::OpenMP_CXX)
endif()
